package negocios;

import java.sql.SQLException;
import java.util.List;

import classes.Cliente;
import dao.IClienteDAO;
import excecao.ClienteExistenteException;
import excecao.ClienteInexistenteException;
import factory.FactoryDAO;

public class CadastroCliente {
	private IClienteDAO clienteDAO;

	// construtor
	public CadastroCliente(){
		this.clienteDAO = FactoryDAO.getClienteDAOImpl();
	}	

	public void atualizarCliente(Cliente c) throws SQLException, ClassNotFoundException, ClienteInexistenteException{
		clienteDAO.atualizar(c);
	}

	public void cadastrarCliente(Cliente c) throws SQLException, ClassNotFoundException, ClienteExistenteException{
		clienteDAO.inserir(c);
	}

	public Cliente consultarCliente(Integer id) throws SQLException, ClassNotFoundException, ClienteInexistenteException{
		Cliente cli_encontrado = clienteDAO.consultarPorId(id);			
		return cli_encontrado;
	}
	
	public void descadastrarCliente(Cliente c) throws SQLException, ClassNotFoundException, ClienteInexistenteException{
		clienteDAO.remover(c.getId());
		
	}
	public List<Cliente> listar(){
		
		return this.clienteDAO.consultarTodos();
		
	}
	
}
